package fr.uvsq.isty.bdh.hchess.gui.game;

import fr.uvsq.isty.bdh.hchess.gui.style.Style;
import java.awt.BorderLayout;
import java.awt.Dimension;
import java.awt.Graphics;
import java.awt.Image;
import java.io.IOException;
import javax.swing.JPanel;

/**
 * A JPanel containing the main in game displays (BoardDisplay, CurrentPlayerDisplay,
 * BlackCapturedPiecesDisplay and WhiteCapturedPiecesDisplay.
 * @author Rémi Dubois <RemiEric.Dubois@gmail.com>
 */
public class MainDisplayContainer extends JPanel {
    
    private Style style; /** Board style singleton */
    
    private BoardDisplay boardDisplay;
    private CurrentPlayerDisplay currentPlayerDisplay;
    private CapturedPieceDisplay blackCapturedPiecesDisplay;
    private CapturedPieceDisplay whiteCapturedPiecesDisplay;
    private OnHoverHelpDisplay onHoverHelpDisplay;
    public MainDisplayContainer() {
        this.setPreferredSize(new Dimension(
                BoardDisplay.DEFAULT_CASE_WIDTH*9,
                BoardDisplay.DEFAULT_CASE_HEIGHT*9));
        
        try {
            this.style = Style.getInstance();
        } catch (IOException ex) {
        }
        
        this.setLayout(new BorderLayout());
        
        this.boardDisplay = new BoardDisplay();
        this.currentPlayerDisplay = new CurrentPlayerDisplay();
        this.blackCapturedPiecesDisplay = new CapturedPieceDisplay(true);
        this.whiteCapturedPiecesDisplay = new CapturedPieceDisplay(false);
        this.onHoverHelpDisplay = null;
        
        this.add(boardDisplay, BorderLayout.CENTER);
        this.add(currentPlayerDisplay, BorderLayout.SOUTH);
        this.add(whiteCapturedPiecesDisplay, BorderLayout.EAST);
        this.add(blackCapturedPiecesDisplay, BorderLayout.WEST);
    }
    
    @Override
    public void paintComponent(Graphics g) {
        Image bg = style.getBGImage();
        
        g.drawImage(bg, 0, 0, this.getWidth(), this.getHeight(), this);
    }

    /**
     * @return the boardDisplay
     */
    public BoardDisplay getBoardDisplay() {
        return boardDisplay;
    }

    /**
     * @return the playerCurrentDisplay
     */
    public CurrentPlayerDisplay getCurrentPlayerDisplay() {
        return currentPlayerDisplay;
    }

    /**
     * @return the blackCapturedPiecesDisplay
     */
    public CapturedPieceDisplay getBlackCapturedPiecesDisplay() {
        return blackCapturedPiecesDisplay;
    }

    /**
     * @return the whiteCapturedPiecesDisplay
     */
    public CapturedPieceDisplay getWhiteCapturedPiecesDisplay() {
        return whiteCapturedPiecesDisplay;
    }

    /**
     * @return the onHoverHelpDisplay
     */
    public OnHoverHelpDisplay getOnHoverHelpDisplay() {
        return onHoverHelpDisplay;
    }
    
    
}
